﻿using System;
using System.Configuration;
using TechTalk.SpecFlow;
using System.Text.RegularExpressions;

namespace Sketch.Test.Acceptance
{
    [Binding]
    public class Parameters
    {
        [StepArgumentTransformation]
        public Uri GetContextParameter(string relativeUrl) 
        {
            relativeUrl = Regex.Replace(relativeUrl, "({.*})", p => ScenarioContext.Current[p.Value].ToString());
            
            var rootUrl = new Uri(ConfigurationManager.AppSettings["RootUrl"]);
            return new Uri(rootUrl, relativeUrl);            
        }
    }
}
